<?php
/**
 * AbstractController.php
 *
 * @author		b.wenneker <b.wenneker@gmail.com>, 2010
 */
class Thesis_AbstractController extends Zend_Controller_Action
{
	
	protected $_contentType = null;
	
	public function init(){
		
		$this->_contentType = $this->getRequest()->getParam('content');
		if(!in_array($this->_contentType, array('page','data'))){
			throw new Exception('Invalid content type found ('. $this->_contentType .').');
		}
		$this->_helper->layout->setLayout('thesis');
	}
	
	public function preDispatch(){
		
		// Initialize navigation.
		$viewRenderer 	= Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
		$viewRenderer	->initView();
		$view 			= $viewRenderer->view;
		
		$config 		= new Zend_Config_Ini(APPLICATION_PATH . '/modules/thesis/configs/navigation.ini', $this->getRequest()->controller);

		$navigation 	= new Zend_Navigation($config);
		$view			->navigation($navigation);
		
		// Configure navigation.
		$uri 					= $this->getRequest()->action;//array_pop(explode('/', $this->getRequest()->getPathInfo()));
		
		$activeNav 				= $this->view->navigation()->findByAction($uri);
		$activeNav->active 		= true;
		
		$activeNav->setClass("active");
		$this->view->assign('activeNav', $activeNav);
	}
	
	protected function _getStore ($port = '8893')
	{
		$config = array('remote_store_endpoint' => 'http://wisserver.st.ewi.tudelft.nl:'. $port .'/sparql');
		return ARC2::getRemoteStore($config);
	}
}